package xuhaijia.lanou3g.autohome.findcar;
//                .-~~~~~~~~~-._       _.-~~~~~~~~~-.
//            __.'              ~.   .~              `.__
//          .'//                  \./                   \\`.
//        .'//            为什么坚持  想一想当初             \\`.
//      .'// .-~"""""""~~~~-._     |     _,-~~~~"""""""~-.  \\`.
//    .'//.-"                 `-.  |  .-'                 "-. \\`.
//  .'//______.============-..   \ | /   ..-============._______\\`.
//.'//____________________________\|/_____________________________\\`.
// 
//                             

import android.graphics.Color;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.support.v4.widget.DrawerLayout;

import java.util.ArrayList;

import xuhaijia.lanou3g.autohome.R;
import xuhaijia.lanou3g.autohome.base.BaseFragment;
import xuhaijia.lanou3g.autohome.findcar.brand.BrandFragment;
import xuhaijia.lanou3g.autohome.findcar.depreciate.DepreciateFragment;
import xuhaijia.lanou3g.autohome.findcar.screen.ScreenFragment;
import xuhaijia.lanou3g.autohome.forum.PrimaryAdapter;


/**
 * Created by dllo on 16/8/15.
 */
public class FindCarFragment extends BaseFragment{

    private PrimaryAdapter primaryAdapter;
    private ViewPager primaryVp;
    private TabLayout primaryTb;
    private ArrayList<String> tbArrayLists;
    private ArrayList<Fragment> fragments;
    private DrawerLayout drawerLayout;
    private ScreenFragment screenFragment;

    @Override
    protected int setLayout() {
        return R.layout.fragment_primary;
    }
    @Override
    protected void initView() {
        primaryAdapter = new PrimaryAdapter(getChildFragmentManager());
        primaryVp = bindView(R.id.primary_vp);
        primaryTb = bindView(R.id.primary_tb);
        drawerLayout = bindView(R.id.main_drawer_layout);
        drawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED);
    }

    @Override
    protected void initData() {
        tbArrayLists = new ArrayList<>();
        tbArrayLists.add("品牌");
        tbArrayLists.add("筛选");
        tbArrayLists.add("降价");
        tbArrayLists.add("找二手车");
        fragments = new ArrayList<>();
        fragments.add(new BrandFragment());
        screenFragment = new ScreenFragment();
        fragments.add(screenFragment);
        fragments.add(new DepreciateFragment());
        fragments.add(new UsedCarFragment());
        primaryAdapter.setFragments(fragments);
        primaryAdapter.setTbArrayLists(tbArrayLists);
        primaryVp.setAdapter(primaryAdapter);
        primaryTb.setupWithViewPager(primaryVp);
        primaryTb.setTabTextColors(Color.BLACK,Color.BLUE);
        primaryTb.setSelectedTabIndicatorColor(Color.BLUE);
        primaryTb.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
            @Override
            public void onTabSelected(TabLayout.Tab tab) {
                if (tab.getPosition() != 1) {
                    screenFragment.closePopWindow();
                    screenFragment.conditionTv.setText("条件 ▼");
                    screenFragment.conditionTv.setTextColor(0xff414348);
                }
            }

            @Override
            public void onTabUnselected(TabLayout.Tab tab) {

            }

            @Override
            public void onTabReselected(TabLayout.Tab tab) {

            }
        });
    }

    @Override
    public void load() {

    }

    @Override
    public void refresh() {

    }
}
